from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
driver = webdriver.Edge()
driver.get('')
action=driver.find_element(By.ID,'a')
# 左击
ActionChains(driver).click(action).perform()
# 右击
ActionChains(driver).context_click(action).perform()
# 悬停
ActionChains(driver).move_to_element(action).perform()
# 双击
ActionChains(driver).double_click(action).perform()
# 按住不放
ActionChains(driver).click_and_hold(action).perform()
# 拖拽
ActionChains(driver).drag_and_drop(action,action).perform()
# xy拖拽
ActionChains(driver).drag_and_drop_by_offset(action,xoffset=800,yoffset=60).perform()
# 释放
ActionChains(driver).release(action).perform()
# 按轴移动
ActionChains(driver).move_by_offset(xoffset=800,yoffset=60)
# 键盘事件
keys= driver.find_element(By.ID,'w')
# 回车
keys.send_keys(Keys.ENTER)
# tab
keys.send_keys(Keys.ALT)
# shift
keys.send_keys(Keys.SHIFT,'')
# f1
keys.send_keys(Keys.F1)
# home
keys.send_keys(Keys.HOME)
# 删除
keys.send_keys(Keys.DELETE)
# end
keys.send_keys(Keys.END)
# Insert
keys.send_keys(Keys.INSERT)
# pause
keys.send_keys(Keys.PAUSE)